package com.zdy.reflection;

import com.zdy.annotion.Test02;

/**
 * Created by 逸足天涯
 * on 3/5/2020.
 */
public class Test07 {

    public static void main(String[] args) throws ClassNotFoundException {
        //获取系统类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        //获取系统类加载器的父类————>扩展类加载器
        ClassLoader parent = systemClassLoader.getParent();
        System.out.println(parent);

        //获取扩展类加载器的父类————>根加载器
        //根加载器无法获取
        ClassLoader parent1 = parent.getParent();
        System.out.println(parent1);

        //获取当前类的类加载器
        Class c1 = Class.forName("com.zdy.reflection.Test07");
        ClassLoader classLoader = c1.getClassLoader();
        System.out.println(classLoader);

        //测试JDK内置的Object 类是谁加载的
        //根加载器无法获取返回null
        ClassLoader classLoader1 = Class.forName("java.lang.Object").getClassLoader();
        System.out.println(classLoader1);

        //获取系统类加载器可以加载的路径
        System.out.println(System.getProperty("java.class.path"));
        //输出结果如下
        /*
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\charsets.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\deploy.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\access-bridge-64.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\cldrdata.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\dnsns.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\jaccess.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\jfxrt.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\localedata.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\nashorn.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\sunec.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\sunjce_provider.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\sunmscapi.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\sunpkcs11.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\ext\zipfs.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\javaws.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\jce.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\jfr.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\jfxswt.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\jsse.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\management-agent.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\plugin.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\resources.jar;
        E:\soft\JAVA\Java\jdk1.8.0_66\jre\lib\rt.jar;
        E:\Java 基础笔记\注解和反射\out\production\注解和反射;
        C:\Program Files\JetBrains\ideaIU-2018.3.6.win\lib\idea_rt.jar
        * */

    }
}
